/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * PanelTipo.java
 *
 * Created on 30/09/2010, 02:01:29
 */
package aprendizadosemfio.Telas;

import aprendizadosemfio.entidades.Subtipo;
import java.util.ArrayList;
import javax.swing.text.MutableAttributeSet;
import javax.swing.text.SimpleAttributeSet;
import javax.swing.text.StyleConstants;
import javax.swing.text.StyledDocument;

/**
 *
 * @author Usuario
 */
public class PanelTipo extends javax.swing.JPanel {

    ArrayList<Subtipo> subtipos;
    int estado = 0;

    /** Creates new form PanelTipo */
    public PanelTipo() {
        initComponents();
        StyledDocument doc = this.AreaTexto.getStyledDocument();

        MutableAttributeSet standard = new SimpleAttributeSet();
        StyleConstants.setAlignment(standard, StyleConstants.ALIGN_JUSTIFIED); //atribui cor vermelha
        StyleConstants.setFontSize(standard, 16);
        StyleConstants.setFontFamily(standard, "TIMES");
        doc.setParagraphAttributes(0, 0, standard, true);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        BotaoRetornar = new javax.swing.JButton();
        TecnologiaImagem = new javax.swing.JLabel();
        BotaoAvancar = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        AreaTexto = new javax.swing.JTextPane();

        setBackground(new java.awt.Color(255, 255, 255));

        BotaoRetornar.setBackground(new java.awt.Color(255, 255, 255));
        BotaoRetornar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resource/back2.PNG"))); // NOI18N
        BotaoRetornar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BotaoRetornarActionPerformed(evt);
            }
        });

        BotaoAvancar.setBackground(new java.awt.Color(255, 255, 255));
        BotaoAvancar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resource/forward2.PNG"))); // NOI18N
        BotaoAvancar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BotaoAvancarActionPerformed(evt);
            }
        });

        AreaTexto.setEditable(false);
        AreaTexto.setFont(new java.awt.Font("Tahoma", 0, 16));
        jScrollPane1.setViewportView(AreaTexto);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(TecnologiaImagem)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 302, Short.MAX_VALUE)
                .addComponent(BotaoRetornar, javax.swing.GroupLayout.PREFERRED_SIZE, 47, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(BotaoAvancar, javax.swing.GroupLayout.PREFERRED_SIZE, 49, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 414, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 227, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(BotaoAvancar, javax.swing.GroupLayout.Alignment.LEADING, 0, 0, Short.MAX_VALUE)
                            .addComponent(BotaoRetornar, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addContainerGap())
                    .addComponent(TecnologiaImagem, javax.swing.GroupLayout.DEFAULT_SIZE, 142, Short.MAX_VALUE)))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void BotaoRetornarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BotaoRetornarActionPerformed
        if (estado != 0) {
            estado--;
        }
        ajustar();
    }//GEN-LAST:event_BotaoRetornarActionPerformed

    private void BotaoAvancarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BotaoAvancarActionPerformed

        if (estado < subtipos.size() - 1) {
            estado++;
        }
        ajustar();
    }//GEN-LAST:event_BotaoAvancarActionPerformed

    public void ajustar() {
        if(subtipos.size()!=0){
        AreaTexto.setText(subtipos.get(estado).getConceito());
        TecnologiaImagem.setIcon(subtipos.get(estado).getImagem());
        AreaTexto.setCaretPosition(0);
        TecnologiaImagem.repaint();}
    }

    public void setSubtipos(ArrayList<Subtipo> subtipos) {
        this.subtipos = subtipos;
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextPane AreaTexto;
    private javax.swing.JButton BotaoAvancar;
    private javax.swing.JButton BotaoRetornar;
    private javax.swing.JLabel TecnologiaImagem;
    private javax.swing.JScrollPane jScrollPane1;
    // End of variables declaration//GEN-END:variables
}
